﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Buisness_Level;

namespace ApplicationIU
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void calculateButton(object sender, EventArgs e)
        {

        }

        private void calculateButton1_Click(object sender, EventArgs e)
        {
        string[] allScores = scoresTextBox.Text.Split (',');
            List<int> intAllScores = new List<int>();

            foreach(string currentElement in allScores)
            {
                // защитный блок
                try
                {
                    intAllScores.Add(Convert.ToInt32(currentElement));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Некорректное значение в поле введения баллов");
                }
                    // защ
            }
             if (studentRadioButton.Checked == true)
            { 
              Student student1 = new Student("Vasiliy", "Vasilievich", "Vasiliev", "IST-212", "230400.62", true);
            resultLable.Text = student1.CalculateScores(intAllScores).ToString();
            }
            
              if (teacherRadioButton.Checked == true)
              {
                  Teacher CurrentTeacher = new Teacher(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
                  CurrentTeacher.BooksCount = Convert.ToInt32(booksCountTextBox.Text); // текст где-то здесь преобразется в числа... через запятую причем
                  CurrentTeacher.ActionsCount = Convert.ToInt32(actionsCountTextBox.Text);
                  resultLable.Text = CurrentTeacher.CalculateScores(intAllScores).ToString() ;
              }


            //scoresTextBox.Text.Split (',');
        
        }

        private void resultLable_Click(object sender, EventArgs e)
        {

        }

        private void studentRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (studentRadioButton.Checked == true)
            {
                teacherRadioButton.Checked = false;
            }
            else
            {
                teacherRadioButton.Checked = true;
            }
        }

        private void teacherRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            {
                if (teacherRadioButton.Checked == true)
                {
                    studentRadioButton.Checked = false;
                }
                else
                {
                    studentRadioButton.Checked = true;
                }
            }

        }

        

        
        }
    }

